package leetcode

// https://leetcode.cn/problems/largest-bst-subtree

func getLargestBST(root *TreeNode) *TreeNode {

	tempStack := make([]*TreeNode, 1)
	tempStack[0] = root

	posOrderStack := make([]*TreeNode, 0)

	for len(tempStack) > 0 {
		cur := tempStack[len(tempStack)-1]
		tempStack = tempStack[:len(tempStack)-1]

		posOrderStack[0] = cur

		if cur.Left != nil {
			tempStack[len(tempStack)-1] = cur.Left
		}

		if cur.Right != nil {
			tempStack[len(tempStack)-1] = cur.Right
		}
	}

	return nil
}
